<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/style.css">
    <title>Document</title>
</head>
<body style="background-color: #000;">
    <audio autoplay="autoplay" src="10787.mp3"></audio>
    <div class="cube-container">

        <div class="cube initial-position">

          <img class="cube-face-image image-1" src="images/xk (1).jpg">

          <img class="cube-face-image image-2" src="images/xk (2).jpg">

          <img class="cube-face-image image-3" src="images/xk (3).jpg">

          <img class="cube-face-image image-4" src="images/xk (4).jpg">

          <img class="cube-face-image image-5" src="images/xk (5).jpg">

          <img class="cube-face-image image-6" src="images/xk (6).jpg">

        </div>

    </div>

    <h2>点击下面的图片来旋转立方体</h2>

    <div class="image-buttons">

        <input type="image" class="show-image-1" src="images/xk (1).jpg"></input>

        <input type="image" class="show-image-2" src="images/xk (2).jpg"></input>

        <input type="image" class="show-image-3" src="images/xk (3).jpg"></input>

        <input type="image" class="show-image-4" src="images/xk (4).jpg"></input>

        <input type="image" class="show-image-5" src="images/xk (5).jpg"></input>

        <input type="image" class="show-image-6" src="images/xk (6).jpg"></input>

    </div>
    <script type="text/javascript">
		//DOM load event
		window.addEventListener("DOMContentLoaded", function () {

			var cube = document.querySelector(".cube"),
			    imageButtons = document.querySelector(".image-buttons");
			var cubeImageClass = cube.classList[1];

			//Add click event listener to image buttons container
			imageButtons.addEventListener("click", function (e) {

				//Get node type and class value of clicked element
				var targetNode = e.target.nodeName,
				    targetClass = e.target.className;

				//Check if image input has been clicked and isn't the currently shown image
				if (targetNode === "INPUT" && targetClass !== cubeImageClass) {

					console.log("Show Image: " + targetClass.charAt(11));

					//Replace previous cube image class with new class
					//cube.classList.replace(cubeImageClass, targetClass);
					cube.classList.remove(cubeImageClass);
					cube.classList.add(targetClass);

					//Update cube image class variable with new class
					cubeImageClass = targetClass;
				}
			});
		});
	</script>
</body>
</html>